import { useState, useEffect } from "react"
export default function usePosition() {
  const [x,setX]=useState(0)
  const [y,setY]=useState(0)
  
  function handle(e){
    setX(e.clientX)
    setY(e.clientY)
  }
  useEffect(()=>{
    window.addEventListener("mousemove",handle)
    return ()=>{
      window.removeEventListener("mousemove",handle)
    }
  })

  return {x,y}
}
